package minisoft.application.loterryservice;

import java.util.List;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ProvinceListAdapter extends BaseAdapter {

	private Context mContext;
	private List<Today> mItems;

	public ProvinceListAdapter(Context c, List<Today> items) {
		mContext = c;
		mItems = items;
	}

	@Override
	public int getCount() {
		return mItems.size();
	}

	@Override
	public Object getItem(int position) {
		return mItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View aView = inflater.inflate(R.layout.province_list_row, null);

		TextView province = (TextView) aView.findViewById(R.id.province);

		province.setText(String.valueOf(mItems.get(position).getProvinceName()));
		
		Log.i("Province", String.valueOf(mItems.get(position).getProvinceName()));

		return aView;
	}

	public void add(Today aToday) {
		mItems.add(aToday);
	}

	public void update(Today aToday, int pos) {
		mItems.set(pos, aToday);
	}

	public void clear() {
		mItems.clear();
	}
}
